declare @lastDate nvarchar(8) = (SELECT MAX_DATE_ENDMONTH FROM DATE_EM_REPORT)
--print @lastDate

delete from ACCOUNT_PLANNING_BL

insert into ACCOUNT_PLANNING_BL
select md_id, (amount_qd* 1e9) org_amount, cust_id, value_date, convert(nvarchar(6), CONVERT(date,from_date),112) as yearmonth
 from SERVER12.TRANGLT9.[DBO].[DOANH_SO_BAO_LANH] where cust_id in (select cif from TBL_ACCOUNT_PLANNING) and from_date >@lastDate
